using System;

namespace Xyne.Objects
{
	public enum PatternValueEnum
	{
		Unknown = 0,
		None,
		Red,
		Blue,
		Green,
		Yellow,
		White,
		Black,
        Length
	}
	
	public class PatternValue
	{
        public static int NumberOfValues = (int)PatternValueEnum.Length;

		private PatternValueEnum val;
		public PatternValueEnum Value
		{
			get { return val; }
			set { val = value; }
		}
		
		public PatternValue()
		{
            this.val = PatternValueEnum.None;
		}
		
		public PatternValue(PatternValueEnum val)
		{
			this.val = val;
		}

        public static bool Matches(PatternValueEnum patternValue, PuzzlePieceColorEnum color)
        {
            switch (patternValue)
            {
                case PatternValueEnum.Red: return color == PuzzlePieceColorEnum.Red;
                case PatternValueEnum.Blue: return color == PuzzlePieceColorEnum.Blue;
                case PatternValueEnum.Green: return color == PuzzlePieceColorEnum.Green;
                case PatternValueEnum.Yellow: return color == PuzzlePieceColorEnum.Yellow;
                case PatternValueEnum.White: return color == PuzzlePieceColorEnum.White;
                case PatternValueEnum.Black: return color == PuzzlePieceColorEnum.Black;
            }

            return false;
        }
		
		public static PatternValue Parse(Char c)
		{
			PatternValue val = new PatternValue();
			if (c == '-') val.Value = PatternValueEnum.None;
			if (c == 'R') val.Value = PatternValueEnum.Red;
			if (c == 'B') val.Value = PatternValueEnum.Blue;
			if (c == 'G') val.Value = PatternValueEnum.Green;
			if (c == 'Y') val.Value = PatternValueEnum.Yellow;
			if (c == 'W') val.Value = PatternValueEnum.White;
			if (c == 'L') val.Value = PatternValueEnum.Black;
			return val;
		}
		
		public override string ToString()
		{
			switch (val)
			{
			case PatternValueEnum.None: return "-";
			case PatternValueEnum.Red: return "R";
			case PatternValueEnum.Blue: return "B";
			case PatternValueEnum.Green: return "G";
			case PatternValueEnum.Yellow: return "Y";
			case PatternValueEnum.White: return "W";
			case PatternValueEnum.Black: return "L";
			default: return "?";
			}
		}

	}
}
